package com.swing.gui.pages;

import base.GeneralBase;
import base.JPanelBase;
import com.swing.assets.Iurl;
import com.swing.gui.pages.lock.One;
import com.swing.gui.pages.lock.Two;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.net.MalformedURLException;
import java.net.URL;

/**
 * 入口 - 点击锁定（初始界面）
 * 窗口将被上锁定（锁定页面）
 * 点击解锁（解锁界面）
 * 以上二个界面将使用（卡片布局）
 *
 * @author Yuang, Gongming
 * @date 2022-01-25 11:18
 */
public class Lock extends JPanel implements JPanelBase {
    private static Lock lock;

    private Lock() {
    }

    public static Lock init() {
        if (lock == null) {
            synchronized (Lock.class) {
                if (lock == null) {
                    lock = new Lock();
                    try {
                        lock.css();
                        lock.planning();
                        lock.event();
                    } catch (Exception e) {
                        throw new RuntimeException(Lock.class.getSimpleName() + "实例化失败！");
                    }

                }
            }
        }
        return lock;
    }

    @Override
    public void css() {
        lock.setLayout(new CardLayout());
    }

    @Override
    public void planning() {
        lock.add(One.init(), "one");
        lock.add(Two.init(), "two");


    }

    @Override
    public void event() {
        //  ignore……
    }

}
